from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
def getDriver(url):
    options = webdriver.ChromeOptions()
    options.binary_location = r".\chrome-win64\chrome.exe"
    options.add_argument("--ignore-certificate-errors")
    options.add_argument('--allow-running-insecure-content')  # 允许不安全内容
    options.add_argument('--log-level=3')  # 只显示致命错误(FATAL)
    #options.add_experimental_option('excludeSwitches', ['enable-logging'])  # 禁用控制台日志
    service = Service(executable_path=r".\chromedriver.exe")
    # 创建一个 Chrome WebDriver 实例
    driver = webdriver.Chrome(service=service,options=options)
    # 打开一个网页
    driver.get(url)

    return driver

__all__ = ["getDriver"]